package com.groupfifteen.dao;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.groupfifteen.entity.SysPaperManageEntity;
import org.apache.ibatis.annotations.*;

import java.util.List;

@Mapper
public interface SysPaperManageDao extends BaseMapper<SysPaperManageEntity> {
    /**
     * 查询所有试卷
     *
     * @return 试卷
     */
    @Select("select paper_id, question_type,question_id from sys_paper_manage")
    List<SysPaperManageEntity> findAll();

    /**
     * 添加试卷
     *
     * @param paperManage 试卷信息
     * @return 结果
     */
    @Insert("insert into sys_paper_manage(paper_id,question_type,question_id) values " +
            "(#{paperId},#{questionType},#{questionId})")
    Integer add(SysPaperManageEntity paperManage);

    /**
     * 删除试卷中的某条试题
     *
     * @param paperId    试卷id
     * @param type       题目类型。1选择，2填空，3判断
     * @param questionId 题目id
     */
    @Delete("delete from sys_paper_manage where paper_id = #{paperId} and question_type = #{type} and question_id = " +
            "#{questionId}")
    void delete(@Param("paperId") String paperId, @Param("type") String type, @Param("questionId") String questionId);
}
